home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
cursors.zip
/
CURSORS.PAS
Wrap
Pascal/Delphi Source File
|
1985-12-07
|
4KB
|
119 lines
PROGRAM CURSORS;
{ This program is a sample on how to control the cursor using TURBO PASCAL
on an IBM or IBM compatable machine. It calls the BIOS VIDEO_IO module
through the standard interupt $10. This will not work with any machine
not supporting the standard interupts into the BIOS roms }
VAR
X : STRING[79];
StartScan : INTEGER;
EndScan : INTEGER;
{--------------------------------------------------------------------------}
PROCEDURE SetCursor (StartLine,EndLine : Integer);
{ This procedure does the actual cursor setting thru the TURBO
INTR procedure. }
TYPE
Register = record
ax,bx,cx,dx,bp,si,ds,es,flags : integer;
end;
VAR
IntrRegs : Register;
CXRegArray : Array [1..2] of Byte;
CXReg : integer absolute CXRegArray;
BEGIN
CXRegArray[2] := LO(StartLine);
CXRegArray[1] := LO(EndLine);
With IntrRegs do
BEGIN
ax := $0100; {ah = 1 means set cursor type}
bx := $0; {bx = page number, zero for us}
cx := CXReg; {ch bits 4 to 0 = start line for cursor}
{cl bits 4 to 0 = end line for cursor}
intr($10,IntrRegs); {set cursor}
END;
END;
{--------------------------------------------------------------------------}
PROCEDURE NoCursor;
{ This procedure calls SetCursor to turn the cursor off }
BEGIN
SetCursor(32,0); {Setting bit 5 turns off cursor}
END;
{--------------------------------------------------------------------------}
PROCEDURE BoxCursor;
{ This procedure calls SetCursor to show a block (box) cursor }
BEGIN
SetCursor(0,13); {0-7 for mono, 0-13 for color}
{but 0-13 works ok for mono too}
END;
{--------------------------------------------------------------------------}
FUNCTION CrtMode : Integer;
{ This procedure call BIOS to determine current CRT mode }
TYPE
Register = record
ax,bx,cx,dx,bp,si,ds,es,flags : integer;
end;
VAR
IntrRegs : Register;
BEGIN
With IntrRegs do
BEGIN
ax := $0F00; {VIDEO_IO function 15}
Intr($10,IntrRegs);
CrtMode := LO(ax);
END;
END;
{--------------------------------------------------------------------------}
PROCEDURE NormCursor;
{ This procedure calls SetCursor to show the 'normal' cursor }
BEGIN
If CrtMode = 7 then
SetCursor(11,12) {mono}
else
SetCursor(6,7); {color}
END;
{--------------------------------------------------------------------------}
BEGIN {Main Program}
ClrScr; {Clear Screen}
GoToXY(1,5); {Row 5, Column 1}
WriteLn('Notice that there is now NO cursor! (Press Enter to continue)');
NoCursor;
ReadLn(X);
GoToXY(1,7);
WriteLn('Now notice the BOX cursor! (Press Enter to continue)');
BoxCursor;
ReadLn(X);
GoToXY(1,9);
WriteLn('Now back to the normal cursor! (Press Enter to continue)');
NormCursor;
ReadLn(X);
StartScan := 1; EndScan := 1;
While (StartScan > 0) or (EndScan > 0) do
BEGIN
GoToXY(1,12);
WriteLn('Now it is time to design your own (enter zero for both to end)');
Write('Enter the topmost scan line for the cursor (0-13):');
ReadLn(StartScan);
Write('Enter the bottom scan line for the cursor (0-13):');
ReadLn(EndScan);
If (StartScan > 0) or (EndScan > 0) then
BEGIN
SetCursor(StartScan,EndScan);
GoToXY(1,15);
WriteLn('Well, here is your cursor:');
ReadLn(X);
END;
END;
NormCursor;
END.